import unittest
import CloudEngine.core.ArrayPlus as core


class MyTestCase(unittest.TestCase):
    def test_ArrayPlus(self):
        # Test case 1: Push an item into the array
        array1 = core.ArrayPlus()
        array1.push(5)
        assert array1.value() == [5]

        # Test case 2: Pop an item from the array
        array2 = core.ArrayPlus([5])
        array2.pop()
        assert array2.value() == []

        # Test case 3: Remove an item from the array
        array3 = core.ArrayPlus([5, 6, 7])
        array3.remove(6)
        assert array3.value() == [5, 7]

        # Test case 4: Drop right n items from the array
        array4 = core.ArrayPlus([5, 6, 7, 8, 9])
        array4.drop_right(2)
        assert array4.value() == [5, 6, 7]

        # Test case 5: Empty the array
        array5 = core.ArrayPlus([5, 6, 7])
        array5.empty()
        assert array5.value() == []

        # Test case 6: For each loop through the array
        def callback(item, index):
            print(f"Item: {item}, Index: {index}")

        array6 = core.ArrayPlus([5, 6, 7])
        array6.for_each(callback)
        # print("All test cases pass")


if __name__ == '__main__':
    unittest.main()
